﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BinarySearchTree
{
    class BinaryTree
    {
        private int? data;
        private BinaryTree left;
        private BinaryTree right;

        public BinaryTree() 
        {
            this.data = null;
        }

        public BinaryTree Right
        {
            get
            {
                return right;
            }
            set
            {
                right = value;
            }
        }

        public BinaryTree Left
        {
            get
            {
                return left;
            }
            set
            {
                left = value;
            }
        }

        public int? Data
        {
            get
            {
                return data;
            }
            set
            {
                data = value;
            }
        }

        public void AddElement(int item) 
        {
            if (this.data == null)
            {
                this.Data = item;
                this.Left = null;
                this.Right = null;
            }
            else 
            {
                if (item < this.Data)
                {
                    this.Left.AddElement(item);
                }
                else 
                {
                    this.Right.AddElement(item);
                }
            }
        }
    }
}
